import request from '@/utils/request'

// 上传头像
export const uploadAvatarService = (data) => {
    return request({
        url: '/user/upload',
        method: 'post',
        data
    })
}

// 获取用户信息
export const getUserInfoService = () => {
    return request({
        url: '/user/profile',
        method: 'get'
    })
}

/**
 * 更新用户的昵称
 * @param {*} data 
 * @returns 
 */
export const updateUserInfoService = (data) => {
    return request({
        url: '/user/profile/username',
        method: 'put',
        data
    })
}

/**
 * 更新用户的密码
 * @param {string} password
 * @param {string} code
 */
export const updatePasswordService = ({ password, code }) => {
    return request({
        url: '/user/profile/passwd',
        method: 'put',
        data: {
            password,
            code
        }
    })
}



/**
 *  升级为宠物侦探
 *  无需传参
 */
export const upgradeToPetFinderService = () => {
    return request({
        url: 'user/roles/pet-detective',
        method: 'post'
    })
}

/**
/* 修改用户密码发送验证码

 */
export const captchaCodeService = () => {
    return request({
        url: '/captcha/edit/passwd',
        method: 'post'
    })
}

/**
 * 注册用户发送验证码
 * @param { string } email
 */
export const captchaCodeRegisterService = ({ email }) => {
    return request({
        url: '/captcha/register',
        method: 'post',
        data: { email }
    })
}

/**
 * 登录发送验证码
 * @param { string } email
 */
export const captchaCodeLoginService = ({ email }) => request({ url: '/captcha/login', method: 'post', data: { email } })